package com.ymttest.database.sqlwapper.sqmarketing;

import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.sqmarketing.MarketingActivity;

public class MarketingActivityWrapper {

	SqlManager manager;

	public MarketingActivityWrapper() {
		manager = new SqlManager("sqmarketing");
	}

	@SuppressWarnings("unchecked")
	public MarketingActivity selectByPrimaryKey(Long id) {

		MarketingActivity marketingActivity = null;

		List<MarketingActivity> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqmarketing.MarketingActivityMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0)
			marketingActivity = result.get(0);

		return marketingActivity;
	}
	
	@SuppressWarnings("unchecked")
	public MarketingActivity selectBySellerId(Long sellerId) {

		MarketingActivity marketingActivity = null;

		List<MarketingActivity> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqmarketing.MarketingActivityMapper.selectBySellerId",
						sellerId);
		manager.commit();

		if (result.size() > 0)
			marketingActivity = result.get(0);

		return marketingActivity;
	}
	
	@SuppressWarnings("unchecked")
	public List<MarketingActivity> selectActivitiesBySellerId(Long sellerId) {

		List<MarketingActivity> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqmarketing.MarketingActivityMapper.selectActivitiesBySellerId",
						sellerId);
		manager.commit();

		return result;
	}
	
	public int deleteAllMarketingActivity(long sellerId) {

		int result = manager
				.update("com.ymttest.database.mapping.sqmarketing.MarketingActivityMapper.deleteAllMarketingActivity",
						sellerId);
		manager.commit();

		return result;
	}
	
	public static void main(String[] args) {
		
		MarketingActivityWrapper wrapper = new MarketingActivityWrapper();

		System.out.println(wrapper.deleteAllMarketingActivity(500002490L));
	}
}
